<?php

/**
 *用户好友值抽奖记录表
 */

namespace App\Models\MainDB\Shareprize;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class ShareprizeGetRecord extends Model
{

    protected $table = 'ln_shareprize_get_record';     //数据库内完整表名

    protected $primaryKey = 'id';    //主键名

    protected $fillable = [
        "id",
        "user_id",
        "month",
        "start_time",
        "end_time",
        "sort",
        "prize_type",
        "cate_id",
        "product_id",
        "product_name",
        "number",
        "prize_choose_type",
        "cost",
        "is_show",
    ];

    public $timestamps = false;

    public function list($uid, $params)
    {

        $where[] = ['user_id', '=', $uid];
        $list = app('model_shareprize_get_record')
            ->select([
                'user_id', 'product_name', 'number', 'prize_type', 'created_at'
            ])
            ->where($where)
            ->orderBy('id', 'desc')
            ->paginate($params['page_size'], ['*'], '', $params['page']);

        return $list;
    }

    public function addAll(array $data)
    {
        $rs = DB::table($this->getTable())->insert($data);
        return $rs;
    }
}
